import request from '../../utils/request';

/**
 * 分页查询审批历史
 * 
 * @param entityId
 * @param businessTypes
 * @param page
 */
export async function getListForPage({ entityId, businessTypes, page }) {
    return request(apiPath.mc + "/api/approvalHistory", {
        method: 'get',
        data: { entityId, businessTypes: businessTypes, page: page.page, size: page.size }
    });
}

/**
 * 分页查询费用变更历史
 * 
 * @param entityId
 * @param businessType
 * @param page
 */
export async function getChargeUpdateForPage({ orderId, entityId, businessTypes, page }) {
    return request(apiPath.mc + "/api/approvalHistory/charge", {
        method: 'get',
        data: { orderId, entityId, businessTypes, page: page.page, size: page.size }
    });
}


	/**
	 * 新增审批历史
	 *
	 * @param approvalHistoryForm
	 * @param bindingResult
	 * @return
	 */
export async function createApprovalHistory( data ) {
    return request(apiPath.mc + "/api/approvalHistory", {
        method: 'post',
        data
    });
}

    /**
	 * 更新审批历史
	 *
	 * @param approvalHistoryForm
	 * @param bindingResult
	 * @return
	 */
export async function updateApprovalHistory( data ) {
    return request(apiPath.mc + "/api/approvalHistory", {
        method: 'put',
        data
    });
}

    /**
	 * 根据id删除审批历史
	 *
	 * @param id
	 * @return
	 */
export async function deleteApprovalHistoryById({ id }) {
    return request(apiPath.mc + "/api/approvalHistory/" + id , {
        method: 'delete'
    });
}

    /**
	 * 根据id获取审批历史
	 *
	 * @param id
	 * @return
	 */
export async function getApprovalHistoryById({ id }) {
    return request(apiPath.mc + "/api/approvalHistory/" + id, {
        method: 'get'
    });
}

	/**
	 * 审批
	 *
	 * @param approvalHistoryForm
	 * @param bindingResult
	 * @return
	 */
export async function approval({ id, result, memo }) {
    return request(apiPath.mc + "/api/approvalHistory/" + id + "/approval", {
        method: 'put',
        data: { id, result, memo }
    });
}
